const connection = require('../db/mysql')

class StadiumService {
    async getById(id) {
        let statement = 'SELECT * FROM stadium WHERE id = ?;'
        let [ result ] = await connection.execute(statement, [id])
        return result
    }

    async list(word) {
        let statement = `SELECT * FROM stadium;`
        !!word && (statement =  `SELECT * FROM stadium WHERE name LIKE '%${word}%' OR ADDRESS LIKE '%${word}%';`)
        let [ result ] = await connection.execute(statement)
        return result
    }
}

module.exports = new StadiumService()